// controller/MathController.java
package com.example.controller;

//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import com.example.Demo1;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/math")
public class MathController {
//    private static final Logger logger = LoggerFactory.getLogger(MathController.class);
    private Demo1 demo = new Demo1();

    @GetMapping("/add")
    public int add(@RequestParam int a, @RequestParam int b) {
//        logger.info("add: {} + {}", a, b);
        return demo.intAdd(a, b);
    }

    @GetMapping("/subtract")
    public int subtract(@RequestParam int a, @RequestParam int b) {
//        logger.info("subtract: {} - {}", a, b);
        return demo.intSubtract(a, b);
    }

    @GetMapping("/multiply")
    public long multiply(@RequestParam int a, @RequestParam int b) {
//        logger.info("multiply: {} * {}", a, b);
        return demo.intMultiply(a, b);
    }

    @GetMapping("/subtract2")
    public int subtract2(@RequestParam int a, @RequestParam int b) {
//        logger.info("subtract2: {} - {}", a, b);
        return demo.intSubtract2(a, b);
    }

    @GetMapping("/length")
    public int getStringLength(@RequestParam String str) {
//        logger.info("getStringLength: {}", str);
        return demo.countlength(str);
    }
}
